package foodmaterial.config;

import foodmaterial.utils.Constants;

public class DataSourceContextHolder {
    static final ThreadLocal<String> contextHolder = new ThreadLocal<String>(){
        /**
         * 将 default 数据源的 key作为默认数据源的 key
         */
        @Override
        protected String initialValue() {
            return Constants.DEFAULT_DATABASE;
        };
    };

    public static  void setDBType(String dbType){
        contextHolder.set(dbType);
    }

    public static String getDBType(){
        return contextHolder.get();
    }

    public static void clearDBType(){
        contextHolder.remove();
    }
}
